package org.siteEncheres.client.seance;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.gwtext.client.widgets.MessageBox;

/**
 * Main entry point.
 *
 * @author Francois
 */
public class FormulaireUpload extends FormPanel{

    private static final String UPLOAD_ACTION_URL = GWT.getModuleBaseURL() + "upload";
    /** 
     * The entry point method, called automatically by loading a module
     * that declares an implementing class as an entry-point
     */
    public FormulaireUpload(FileUpload upload) {
        // Create a FormPanel and point it at a service.
        this.setAction(UPLOAD_ACTION_URL);

        // Because we're going to add a FileUpload widget, we'll need to set the
        // form to use the POST method, and multipart MIME encoding.
        this.setEncoding(FormPanel.ENCODING_MULTIPART);
        this.setMethod(FormPanel.METHOD_POST);

        upload.setName("uploadFormElement");
        this.add(upload);
    

        // Add an event handler to the form.
        this.addSubmitHandler(new FormPanel.SubmitHandler() {

            public void onSubmit(SubmitEvent event) {
            }
        });

        this.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
            public void onSubmitComplete(SubmitCompleteEvent event) {
                MessageBox.alert(event.getResults());
            }
        });
    }
}
